package com.user.basic.analyze.age;

import com.entity.analyze.Age;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface AgeAnalyzeMapper {
    @Select("SELECT birthday FROM user " +
            "WHERE birthday BETWEEN #{startDateTime} AND #{endDateTime} " +
            "ORDER BY birthday DESC")
    List<Date> selectByBirthday(Date startDateTime, Date endDateTime);

    @Select("SELECT count(birthday) FROM user WHERE birthday BETWEEN #{startDateTime} AND #{endDateTime}")
    int count(Date startDateTime, Date endDateTime);

    @Insert("INSERT INTO age(id, name, total, percent, create_time) " +
            "VALUES (#{id}, #{name}, #{total}, #{percent}, #{createTime})")
    void save(Age age);
}
